package stocks;

import cartago.Artifact;
import cartago.OPERATION;
import cartago.ObsProperty;

public class MoneyArt extends Artifact {

	double myMoney = 1000000.00;
	String agentName = "";
	
    @OPERATION public void init(String agentName)  {
        // observable properties
    	defineObsProperty("money",myMoney);
    	this.agentName = agentName;
    }

    @OPERATION public double getMoney()  {
    	return getObsProperty("money").doubleValues();
    }
    	 
    @OPERATION public void buy(double price, int quantity, String stock)  {
    	myMoney-=price*quantity;
        ObsProperty opCurrentValue  = getObsProperty("money");
        opCurrentValue.updateValue(myMoney);
    	
    	
    }

    @OPERATION public void sell(double price, int quantity, String stock)  {
    	myMoney+=price*quantity;
        ObsProperty opCurrentValue  = getObsProperty("money");
        opCurrentValue.updateValue(myMoney);
    }
}
